# -*- coding: utf-8 -*-
"""
@Time ： 2023/9/10 20:56
@Auth ： y.h
@File ：data_visualization.py
@IDE ：PyCharm
@Motto：The sooner you start to code, the longer the program will take. —— Roy Carlson
"""
# 数据可视化

from tkinter import messagebox
import webbrowser as wb
import tkinter
from pythonProjectTemplate.Lib.site_packages.pyecharts import options as opts
from pythonProjectTemplate.Lib.site_packages.pyecharts.globals import ThemeType
from pythonProjectTemplate.Lib.site_packages.pyecharts.charts import Bar, Timeline, Grid, Page
from pythonProjectTemplate.Utils.data_vis_rander_path import get_rander, get_vis_resources_path

__all__ = ["canvas_bar", "page_simple_layout"]

# todo 先不做,有需要再做,不然时间不够
def canvas_bar(data_list: list):
    bar = Bar()
    bar.theme = ThemeType.WHITE
    bar.width = "100%"
    bar.height = "45em"

    bar.add_xaxis(["a", "b", "c", "d"])
    bar.add_yaxis("测试", [1, 2, 3, 4])
    bar.set_global_opts(
        title_opts=opts.TitleOpts(title="标题"),
        datazoom_opts=[opts.DataZoomOpts()],
    )
    page_name = "rander"

    bar.render(get_rander(page_name))
    # todo 这段代码需要封装为方法 start
    root = tkinter.Tk()
    root.withdraw()
    # todo end
    flag = messagebox.askquestion("提示", "是否生成当前页面的数据可视化?")
    if flag == "yes":
        wb.open(get_vis_resources_path(page_name))


def page_simple_layout():
    # fixme Pyecharts包出了点问题,待修复
    pass


if __name__ == '__main__':
    canvas_bar([])
